/******************************************************************************/
/* modem_def.h                                                                */
/******************************************************************************/

#ifndef __MODEM_DEF_H
#define __MODEM_DEF_H


/***************************** MODEM constants ********************************/
#define MD_BUFF_LEN           (300)

#define MODEM_CMD_END_EVENT   (0x00000001)
#define MODEM_CMD_ERR_EVENT   (0x00000002)

#define MODEM_DATA_TX_EVENT   (0x00000001)
#define MODEM_DATAOK_RX_EVENT (0x00000001)

/************************** Prototypes struct for MODEM ***********************/
typedef enum
{
    eMD_MODEM_ON = 0,
    eMD_MODEM_OFF,
    eMD_SMS_READ,
    eMD_SMS_SEND,
    eMD_SMS_DEL,
    eMD_SEND_DATA,
    eMD_TCP_STACK_START,
    eMD_GPRS_CONNECT,
    eMD_TCP_CONNECT,
    eMD_TCP_AT_MODE,
    eMD_TCP_TRANSPARENT_MODE,
    eMD_TCP_CLOSE,
    eMD_SRV_CONNECT,
    eMD_SRV_DISCONNECT,
    eMD_CMD_END
} __eMD_CMD;


typedef enum
{
    eMD_SMS_DIN = 0,
    eMD_SMS_AIN,
    eMD_SMS_TEMP,
    eMD_SMS_GENERIC
} __eMD_SMS_TYPE;


typedef enum
{
    eMD_STATS_NOT_PRESENT = 0,
    eMD_STATS_NOT_LINK,
    eMD_STATS_NOT_SIM,
    eMD_STATS_INITIALIZATION,
    eMD_STATS_READY,
    eMD_STATS_SENDING
} __eMD_STATUS;


typedef struct
MD_ANSW_DATA
{
    MD_ANSW_DATA() : pData(0), dataLen(0) {}

    uint8_t * pData;
    uint32_t dataLen;
} __MD_ANSW_DATA;


typedef struct
MD_CMD_DATA
{
    MD_CMD_DATA() : cmd(eMD_CMD_END), data(0) {}

    uint32_t cmd;
    void * data;
} __MD_CMD_DATA;


typedef struct
MD_CMD
{
    MD_CMD() : strCmd(0), answNum(0), timeout(300) {}

    int8_t * strCmd;
    int8_t * pStrAnsw[3];
    uint32_t answNum;
    uint32_t timeout;
} __MD_CMD;


typedef struct
MD_INFO
{
    MD_INFO() {
        mdManufId[0] = 0;
        mdModel[0] = 0;
        mdFwRev[0] = 0;
        mdImei[0] = 0;
    }

    uint8_t mdManufId[16];
    uint8_t mdModel[16];
    uint8_t mdFwRev[32];
    uint8_t mdImei[16];
} __MD_INFO;


typedef struct
MD_SIM_INFO
{
    MD_SIM_INFO() {
        simOps[0] = 0;
        gsmSq[0] = 0;
        smsSc[0] = 0;
        smsNum[0] = 0;
    }

    uint8_t simOps[32];
    uint8_t gsmSq[6];
    uint8_t smsSc[13];
    uint8_t smsNum[3];
} __MD_SIM_INFO;


typedef struct
MD_SMS_INFO
{
    MD_SMS_INFO() {
        smsSenderNum[0] = 0;
    }

    uint8_t smsSenderNum[13];
} __MD_SMS_INFO;


typedef struct
MD_STATUS_FLG
{
    MD_STATUS_FLG() : isCmdRun(FALSE_T), isPinOk(FALSE_T),
                      isFunOk(FALSE_T), isRegOk(FALSE_T) {}

    bool_t isCmdRun;
    bool_t isPinOk;
    bool_t isFunOk;
    bool_t isRegOk;
} __MD_STATUS_FLG;


typedef struct
MD_TCP_TOOLS
{
    MD_TCP_TOOLS() : isTcpConn(FALSE_T), isGprsConn(FALSE_T),
                     isTransparentMode(FALSE_T), sockIdx(0) {}

    bool_t isTcpConn;
    bool_t isGprsConn;
    bool_t isTransparentMode;
    uint32_t sockIdx;
} __MD_TCP_TOOLS;


typedef struct
MD_PARSING_TOOLS
{
    MD_PARSING_TOOLS() : dataLen(0), timeout(0) {}

    uint8_t buff[MD_BUFF_LEN];
    uint32_t dataLen;
    uint32_t timeout;
} __MD_PARSING_TOOLS;


typedef struct
MD_DATA
{
    MD_DATA() : pData(0), dataLen(0) {}

    const uint8_t * pData;
    uint32_t dataLen;
} __MD_DATA;


typedef struct
MD_SMS
{
    MD_SMS() : pScNum(0), pDstNum(0) {}

    int8_t * pScNum;
    int8_t * pDstNum;
    __MD_DATA data;
} __MD_SMS;


typedef union
MD_IP
{
    MD_IP() : ip_32(0) {}

    uint32_t ip_32;
    uint16_t ip_16[2];
    uint8_t  ip_8[4];
} __MD_IP;


#pragma pack(1)
typedef struct
MD_SRV
{
    MD_SRV() : type(0), port(0) {}

    uint16_t type;
    __MD_IP ip;
    uint16_t port;
} __MD_SRV;
#pragma pack()



#endif